﻿﻿//﻿var jq = jQuery.noConflict();
/**
 * 增删改工具栏
 */
/*window.onerror = function() {
	return true;
};*/
var iframe;// iframe操作对象
var win;//窗口对象
/**by:xiu**/
var myWindow = undefined;//弹出的第一个dialog时所在页面的window对象
var myTabWin = undefined;//新加tab时的window
var gridname="";//操作datagrid对象名称
var windowapi = frameElement != undefined ? frameElement.api : undefined, W = windowapi != undefined ? windowapi.opener : undefined;//内容页中调用窗口实例对象接口
/**
 * 关闭当前mail选中的tab页
 */
function closeCurrentTab(title){
    if(title != undefined){
        top.$('#maintabs').tabs('close',title);
    }else{
        var tab = top.$('#maintabs').tabs('getSelected');
        var index = top.$('#maintabs').tabs('getTabIndex',tab);
        top.$('#maintabs').tabs('close',index);
    }

}
function upload(curform) {
	upload();
}
/**
 * 添加事件打开窗口
 * @param title 编辑框标题
 * @param addurl//目标页面地址
 */
function add(title,addurl,gname,width,height) {
	gridname=gname;
	createwindow(title, addurl,width,height);
}
/**
 * 树列表添加事件打开窗口
 * @param title 编辑框标题
 * @param addurl//目标页面地址
 */
function addTreeNode(title,addurl,gname) {
	if (rowid != '') {
		addurl += '&id='+rowid;
	}
	gridname=gname;
	createwindow(title, addurl);
}
/**
 * 更新事件打开窗口
 * @param title 编辑框标题
 * @param addurl//目标页面地址
 * @param id//主键字段
 */
function update(title,url, id,width,height) {
	gridname=id;
	var rowsData = $('#'+id).datagrid('getSelections');
	if (!rowsData || rowsData.length==0) {
		tip('请选择需要编辑的项');
		return;
	}
	if (rowsData.length>1) {
		tip('请选择一条记录再编辑');
		return;
	}
	
	url += '&id='+rowsData[0].id;
	createwindow(title,url,width,height);
}

/**
 * 如果页面是详细查看页面，无效化所有表单元素，只能进行查看
 */
$(function(){
	if(location.href.indexOf("load=detail")!=-1){
		$(":input").attr("disabled","true");
		//$(":input").attr("style","border:0;border-bottom:1 solid black;background:white;");
	}
});

/**
 * 查看详细事件打开窗口
 * @param title 查看框标题
 * @param addurl//目标页面地址
 * @param id//主键字段
 */
function detail(title,url, id,width,height) {
	var rowsData = $('#'+id).datagrid('getSelections');
//	if (rowData.id == '') {
//		tip('请选择查看项目');
//		return;
//	}
	
	if (!rowsData || rowsData.length == 0) {
		tip('请选择查看项目');
		return;
	}
	if (rowsData.length > 1) {
		tip('请选择一条记录再查看');
		return;
	}
    url += '&load=detail&id='+rowsData[0].id;
	createdetailwindow(title,url,width,height);
}

/**
 * 多记录刪除請求
 * @param title
 * @param url
 * @param gname
 * @return
 */
function deleteALLSelect(title,url,gname) {
	gridname=gname;
    var ids = [];
    var rows = $("#"+gname).datagrid('getSelections');
    if (rows.length > 0) {
    	$.dialog.confirm('你确定永久删除该数据吗?', function(r) {
		   if (r) {
				for ( var i = 0; i < rows.length; i++) {
					ids.push(rows[i].id);
				}
				$.ajax({
					url : url,
					type : 'post',
					data : {
						ids : ids.join(',')
					},
					cache : false,
					success : function(data) {
						var d = $.parseJSON(data);
						if (d.success) {
							var msg = d.msg;
							tip(msg);
							reloadTable();
							$("#"+gname).datagrid('unselectAll');
							ids='';
						}
					}
				});
			}
		});
	} else {
		tip("请选择需要删除的数据");
	}
}

/**
 * 查看时的弹出窗口
 * 
 * @param title
 * @param addurl
 * @param saveurl
 */
function createdetailwindow(title, addurl,width,height) {
	width = width?width:700;
	height = height?height:400;
	if(width=="100%" || height=="100%"){
		width = window.top.document.body.offsetWidth;
		height =window.top.document.body.offsetHeight-100;
	}
	if(typeof(windowapi) == 'undefined'){
		$.dialog({
			content: 'url:'+addurl,
			lock : true,
			width:width,
			height: height,
			title:title,
			opacity : 0.3,
			cache:false, 
		    cancelVal: '关闭',
		    cancel: true /*为true等价于function(){}*/
		}).zindex();
	}else{
		W.$.dialog({
			content: 'url:'+addurl,
			lock : true,
			width:width,
			height: height,
			parent:windowapi,
			title:title,
			opacity : 0.3,
			cache:false, 
		    cancelVal: '关闭',
		    cancel: true /*为true等价于function(){}*/
		}).zindex();
	}
	
}
/**
 * 全屏编辑
 * @param title 编辑框标题
 * @param addurl//目标页面地址
 * @param id//主键字段
 */
function editfs(title,url) {
	var name=gridname;
	 if (rowid == '') {
		tip('请选择需要编辑的项');
		return;
	}
	url += '&id='+rowid;
	openwindow(title,url,name,800,500);
}
// 删除调用函数
function delObj(url,name) {
	gridname=name;
	createdialog('删除确认 ', '确定删除该记录吗 ?', url,name);
}
// 删除调用函数
function confuploadify(url, id) {
	$.dialog.confirm('确定删除吗', function(){
		deluploadify(url, id);
	}, function(){
	}).zindex();
}
/**
 * 执行删除附件
 * 
 * @param url
 * @param index
 */
function deluploadify(url, id) {
	$.ajax({
		async : false,
		cache : false,
		type : 'POST',
		url : url,// 请求的action路径
		error : function() {// 请求失败处理函数
		},
		success : function(data) {
			var d = $.parseJSON(data);
			if (d.success) {
				$("#" + id).remove();// 移除SPAN
				m.remove(id);// 移除MAP对象内字符串
			}

		}
	});
}
// 普通询问操作调用函数
function confirm(url, content,name) {
	createdialog('提示信息 ', content, url,name);
}
/**
 * 提示信息
 */
function tip_old(msg) {
	$.dialog.setting.zIndex = 1980;
	$.dialog.tips(msg, 1);
}
/**
 * 提示信息
 */
function tip(msg) {
	$.dialog.setting.zIndex = 1980;
	$.messager.show({
		title : '提示信息',
		msg : msg,
		timeout : 1000 * 6
	});
}
/**
 * 提示信息像alert一样
 */
function alertTip(msg,title) {
	$.dialog.setting.zIndex = 1980;
	title = title?title:"提示信息";
	$.dialog({
			title:title,
			icon:'tips.gif',
			content: msg
		}).zindex();
}
/**
 * 创建添加或编辑窗口
 * 
 * @param title
 * @param addurl
 * @param saveurl
 */
function createwindow(title, addurl,width,height) {
	width = width?width:700;
	height = height?height:400;
	if(width=="100%" || height=="100%" || width=="100%px" || height=="100%px"){
		width = window.top.document.body.offsetWidth;
		height =window.top.document.body.offsetHeight-100;
	}
    //--author：JueYue---------date：20140427---------for：弹出bug修改,设置了zindex()函数
	if(typeof(windowapi) == 'undefined'){
		$.dialog({
			content: 'url:'+addurl,
			lock : true,
			//zIndex:1990,
			width:width,
			height:height,
			title:title,
			opacity : 0.3,
			cache:false,
		    ok: function(){
		    	iframe = this.iframe.contentWindow;
				saveObj();
				return false;
		    },
		    init:function(){
		    	top.myWindow = window;
			},
		    cancelVal: '关闭',
		    cancel: true /*为true等价于function(){}*/
		}).zindex();
	}else{
		W.$.dialog({
			content: 'url:'+addurl,
			lock : true,
			width:width,
			//zIndex:1990,
			height:height,
			parent:windowapi,
			title:title,
			opacity : 0.3,
			cache:false,
		    ok: function(){
		    	iframe = this.iframe.contentWindow;
				saveObj();
				return false;
		    },
		    init:function(){
		    	top.myWindow = window;
			},
		    cancelVal: '关闭',
		    cancel: true /*为true等价于function(){}*/
		}).zindex();
	}
    //--author：JueYue---------date：20140427---------for：弹出bug修改,设置了zindex()函数
	
}
/**
 * 创建上传页面窗口
 * 
 * @param title
 * @param addurl
 * @param saveurl
 */
function openuploadwin(title, url,name,width, height) {
	gridname=name;
	$.dialog({
	    content: 'url:'+url,
	    cache:false,
	    button: [
	        {
	            name: "开始上传",
	            callback: function(){
	            	iframe = this.iframe.contentWindow;
					iframe.upload();
					return false;
	            },
	            focus: true
	        },
	        {
	            name: "取消上传",
	            callback: function(){
	            	iframe = this.iframe.contentWindow;
					iframe.cancel();
	            }
	        }
	    ]
	}).zindex();
}
/**
 * 创建查询页面窗口
 * 
 * @param title
 * @param addurl
 * @param saveurl
 */
function opensearchdwin(title, url, width, height) {
	$.dialog({
		content: 'url:'+url,
		title : title,
		lock : true,
		height : height,
		cache:false,
		width : width,
		opacity : 0.3,
		button : [ {
			name : '查询',
			callback : function() {
				iframe = this.iframe.contentWindow;
				iframe.searchs();
			},
			focus : true
		}, {
			name : '取消',
			callback : function() {

			}
		} ]
	}).zindex();
}
/**
 * 创建不带按钮的窗口
 * 
 * @param title
 * @param addurl
 * @param saveurl
 */
function openwindow(title, url,name, width, height) {
	gridname=name;
	if(width=="100%" || height=="100%"){
		width = window.top.document.body.offsetWidth;
		height =window.top.document.body.offsetHeight-100;
	}
	if (typeof (width) == 'undefined'&&typeof (height) != 'undefined')
	{
		if(typeof(windowapi) == 'undefined'){
			$.dialog({
				content: 'url:'+url,
				title : title,
				cache:false,
				lock : true,
				width: 'auto',
			    height: height
			}).zindex();
		}else{
			$.dialog({
				content: 'url:'+url,
				title : title,
				cache:false,
				parent:windowapi,
				lock : true,
				width: 'auto',
			    height: height
			}).zindex();
		}
	}
	if (typeof (height) == 'undefined'&&typeof (width) != 'undefined')
	{
		if(typeof(windowapi) == 'undefined'){
			$.dialog({
				content: 'url:'+url,
				title : title,
				lock : true,
				width: width,
				cache:false,
			    height: 'auto'
			}).zindex();
		}else{
			$.dialog({
				content: 'url:'+url,
				title : title,
				lock : true,
				parent:windowapi,
				width: width,
				cache:false,
			    height: 'auto'
			}).zindex();
		}
	}
	if (typeof (width) == 'undefined'&&typeof (height) == 'undefined')
	{
		if(typeof(windowapi) == 'undefined'){
			$.dialog({
				content: 'url:'+url,
				title : title,
				lock : true,
				width: 'auto',
				cache:false,
			    height: 'auto'
			}).zindex();
		}else{
			$.dialog({
				content: 'url:'+url,
				title : title,
				lock : true,
				parent:windowapi,
				width: 'auto',
				cache:false,
			    height: 'auto'
			}).zindex();
		}
	}
	
	if (typeof (width) != 'undefined'&&typeof (height) != 'undefined')
	{
		if(typeof(windowapi) == 'undefined'){
			$.dialog({
				width: width,
			    height:height,
				content: 'url:'+url,
				title : title,
				cache:false,
				lock : true,
				init:function (){
					top.myWindow = this;
				}
			}).zindex();
		}else{
			$.dialog({
				width: width,
			    height:height,
				content: 'url:'+url,
				parent:windowapi,
				title : title,
				cache:false,
				lock : true
			}).zindex();
		}
	}
}

/**
 * 创建询问窗口
 * 
 * @param title
 * @param content
 * @param url
 */
function createdialog(title, content, url,name) {
	if(content == ''){
		doSubmit(url,name);
		rowid = '';
	}else{
		$.dialog.confirm(content, function(){
			doSubmit(url,name);
			rowid = '';
		}, function(){
		}).zindex();
	}
}
/**
 * 执行保存
 * 
 * @param url
 * @param gridname
 */
function saveObj() {
	$('#btn_sub', iframe.document).click();
}

/**
 * 执行AJAX提交FORM
 * 
 * @param url
 * @param gridname
 */
function ajaxSubForm(url) {
	$('#myform', iframe.document).form('submit', {
		url : url,
		onSubmit : function() {
			iframe.editor.sync();
		},
		success : function(r) {
			tip('操作成功');
			reloadTable();
		}
	});
}
/**
 * 执行查询
 * 
 * @param url
 * @param gridname
 */
function search() {

	$('#btn_sub', iframe.document).click();
	iframe.search();
}

/**
 * 执行操作
 * 
 * @param url
 * @param index
 */
function doSubmit(url,name,data) {
	gridname=name;
	//--author：JueYue ---------date：20140227---------for：把URL转换成POST参数防止URL参数超出范围的问题
	var paramsData = data;
	if(!paramsData){
		paramsData = {};
		if (url.indexOf("&") != -1) {
			var str = url.substr(url.indexOf("&")+1);
			url = url.substr(0,url.indexOf("&"));
			var strs = str.split("&");
			for(var i = 0; i < strs.length; i ++) {
				paramsData[strs[i].split("=")[0]]=(strs[i].split("=")[1]);
			}
		}      
	}
	//--author：JueYue ---------date：20140227---------for：把URL转换成POST参数防止URL参数超出范围的问题
	$.ajax({
		async : false,
		cache : false,
		type : 'POST',
		data : paramsData,
		url : url,// 请求的action路径
		error : function() {// 请求失败处理函数
		},
		success : function(data) {
			var d = $.parseJSON(data);
			if (d.success) {
				var msg = d.msg;
				tip(msg);
				reloadTable();
			}
		}
	});
	
	
}
/**
 * 退出确认框
 * 
 * @param url
 * @param content
 * @param index
 */
function exit(url, content) {
	$.dialog.confirm(content, function(){
		window.location = url;
	}, function(){
	}).zindex();
}
/**
 * 模板页面ajax提交
 * 
 * @param url
 * @param gridname
 */
function ajaxdoSub(url, formname) {
	$('#' + formname).form('submit', {
		url : url,
		onSubmit : function() {
			editor.sync();
		},
		success : function(r) {
			tip('操作成功');
		}
	});
}
/**
 * ajax提交FORM
 * 
 * @param url
 * @param gridname
 */
function ajaxdoForm(url, formname) {
	$('#' + formname).form('submit', {
		url : url,
		onSubmit : function() {
		},
		success : function(r) {
			tip('操作成功');
		}
	});
}

function opensubwin(title, url, saveurl, okbutton, closebutton) {
	$.dialog({
		content: 'url:'+url,
		title : title,
		lock : true,
		opacity : 0.3,
		button : [ {
			name : okbutton,
			callback : function() {
				iframe = this.iframe.contentWindow;
				win = frameElement.api.opener;// 来源页面
				$('#btn_sub', iframe.document).click();
				return false;
			}
		}, {
			name : closebutton,
			callback : function() {
			}
		} ]

	}).zindex();
}

function openauditwin(title, url, saveurl, okbutton, backbutton, closebutton) {
	$.dialog({
		content: 'url:'+url,
		title : title,
		lock : true,
		opacity : 0.3,
		button : [ {
			name : okbutton,
			callback : function() {
				iframe = this.iframe.contentWindow;
				win = $.dialog.open.origin;// 来源页面
				$('#btn_sub', iframe.document).click();
				return false;
			}
		}, {
			name : backbutton,
			callback : function() {
				iframe = this.iframe.contentWindow;
				win = frameElement.api.opener;// 来源页面
				$('#formobj', iframe.document).form('submit', {
					url : saveurl + "&code=exit",
					onSubmit : function() {
						$('#code').val('exit');
					},
					success : function(r) {
						$.dialog.tips('操作成功', 2);
						win.location.reload();
					}
				});

			}
		}, {
			name : closebutton,
			callback : function() {
			}
		} ]

	}).zindex();
}
/*获取Cookie值*/
function getCookie(c_name)
{
	if (document.cookie.length > 0) {
		c_start = document.cookie.indexOf(c_name + "=");
		if (c_start != -1) {
			c_start = c_start + c_name.length + 1;
			c_end = document.cookie.indexOf(";", c_start);
			if (c_end == -1)
				c_end = document.cookie.length;
			return unescape(document.cookie.substring(c_start, c_end));
		}
	}
	return "";
}
// 添加标签
function addOneTab(subtitle, url, icon) {
	top.myTabWin = this.window;
	var indexStyle = getCookie("JEECGINDEXSTYLE");
	if(indexStyle=='sliding'||indexStyle=='bootstrap'){
		//shortcut和bootstrap风格的tab跳转改为直接跳转
		window.location.href=url;
	}else{
		if (icon == '') {
			icon = 'icon folder';
		}
		window.top.$.messager.progress({
			text : '页面加载中....',
			interval : 300
		});
		window.top.$('#maintabs').tabs({
			onClose : function(subtitle, index) {
				try {
					window.top.$.messager.progress('close');
				} catch (e) {
				}
			}
		});
		if (window.top.$('#maintabs').tabs('exists', subtitle)) {
			window.top.$('#maintabs').tabs('select', subtitle);
			if (url.indexOf('isHref') != -1) {
				window.top.$('#maintabs').tabs('update', {
					tab : window.top.$('#maintabs').tabs('getSelected'),
					options : {
						title : subtitle,
						href:url,
						//content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
						closable : true,
						icon : icon
					}
				});
			}else {
				window.top.$('#maintabs').tabs('update', {
					tab : window.top.$('#maintabs').tabs('getSelected'),
					options : {
						title : subtitle,
						content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
						//content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
						closable : true,
						icon : icon
					}
				});
			}
		} else {
			if (url.indexOf('isHref') != -1) {
				window.top.$('#maintabs').tabs('add', {
					title : subtitle,
					href:url,
					closable : true,
					icon : icon
				});
			}else {
				window.top.$('#maintabs').tabs('add', {
					title : subtitle,
					content : '<iframe src="' + url + '" frameborder="0" style="border:0;width:100%;height:99.4%;"></iframe>',
					closable : true,
					icon : icon
				});
			}
		}
	}
}
// 关闭自身TAB刷新父TABgrid
function closetab(title) {
	//暂时先不刷新
	//window.top.document.getElementById('tabiframe').contentWindow.reloadTable();
	//window.top.document.getElementById('maintabs').contentWindow.reloadTable();
	window.top.$('#maintabs').tabs('close', title);
	//tip("添加成功");
}
/**
 * @author xlThinkPad
 * 获取 easyui tab 下的contentWindow
 * @param titleOrIndex tab 的名字或者 index
 * @returns tab对应的contentWindow
 */
function getMainTabWin(titleOrIndex){
	if(titleOrIndex){
		var tab = window.top.$("#maintabs").tabs("getTab",titleOrIndex);
		var tabWin = undefined;
		if(tab && tab.find("iframe").length > 0){
			tabWin = tab.find("iframe")[0].contentWindow;
		}
		return tabWin;
	}
}
//popup  
//object: this  name:需要选择的列表的字段  code:动态报表的code
function inputClick(obj,name,code) {
	 $.dialog.setting.zIndex = 2000;
	 if(name==""||code==""){
		 alert("popup参数配置不全");
		 return;
	 }
	 if(typeof(windowapi) == 'undefined'){
		 $.dialog({
				content: "url:cgReportController.do?popup&id="+code,
				lock : true,
				title:"选择",
				width:800,
				height: 400,
				cache:false,
			    ok: function(){
			    	iframe = this.iframe.contentWindow;
			    	var selected = iframe.getSelectRows();
			    	if (selected == '' || selected == null ){
				    	alert("请选择");
			    		return false;
				    }else {
					    var str = "";
				    	$.each( selected, function(i, n){
					    	if (i==0)
					    	str+= n[name];
					    	else
				    		str+= ","+n[name];
				    	});
				    	$(obj).val("");
				    	//$('#myText').searchbox('setValue', str);
					    $(obj).val(str);
				    	return true;
				    }
					
			    },
			    cancelVal: '关闭',
			    cancel: true /*为true等价于function(){}*/
			}).zindex();
		}else{
			$.dialog({
				content: "url:cgReportController.do?popup&id="+code,
				lock : true,
				title:"选择",
				width:800,
				height: 400,
				parent:windowapi,
				cache:false,
			    ok: function(){
			    	iframe = this.iframe.contentWindow;
			    	var selected = iframe.getSelectRows();
			    	if (selected == '' || selected == null ){
				    	alert("请选择");
			    		return false;
				    }else {
					    var str = "";
				    	$.each( selected, function(i, n){
					    	if (i==0)
					    	str+= n[name];
					    	else
				    		str+= ","+n[name];
				    	});
				    	$(obj).val("");
				    	//$('#myText').searchbox('setValue', str);
					    $(obj).val(str);
				    	return true;
				    }
					
			    },
			    cancelVal: '关闭',
			    cancel: true /*为true等价于function(){}*/
			}).zindex();
		}
}
/*
	自定义url的弹出
	obj:要填充的控件,可以为多个，以逗号分隔
	name:列表中对应的字段,可以为多个，以逗号分隔（与obj要对应）
	url：弹出页面的Url
*/
function popClick(obj,name,url) {
	 $.dialog.setting.zIndex = 2001;
	var names = name.split(",");
	var objs = obj.split(",");
	 if(typeof(windowapi) == 'undefined'){
		 $.dialog({
				content: "url:"+url,
				lock : true,
				title:"选择",
				width:700,
				height: 400,
				cache:false,
			    ok: function(){
			    	iframe = this.iframe.contentWindow;
			    	var selected = iframe.getSelectRows();
			    	if (selected == '' || selected == null ){
				    	alert("请选择");
			    		return false;
				    }else {
				    	for(var i1=0;i1<names.length;i1++){
						    var str = "";
					    	$.each( selected, function(i, n){
						    	if (i==0)
						    	str+= n[names[i1]];
						    	else{
									str+= ",";
									str+=n[names[i1]];
								}
					    	});
							if($("#"+objs[i1]).length>=1){
								$("#"+objs[i1]).val("");
								$("#"+objs[i1]).val(str);
							}else{
								$("input[name='"+objs[i1]+"']").val("");
								$("input[name='"+objs[i1]+"']").val(str);
							}
						 }
				    	return true;
				    }
					 
			    },
			    cancelVal: '关闭',
			    cancel: true /*为true等价于function(){}*/
			}).zindex();
		}else{
			$.dialog({
				content: "url:"+url,
				lock : true,
				title:"选择",
				width:700,
				height: 400,
				parent:windowapi,
				cache:false,
			     ok: function(){
			    	iframe = this.iframe.contentWindow;
			    	var selected = iframe.getSelectRows();
			    	if (selected == '' || selected == null ){
				    	alert("请选择");
			    		return false;
				    }else {
				    	for(var i1=0;i1<names.length;i1++){
						    var str = "";
					    	$.each( selected, function(i, n){
						    	if (i==0)
						    	str+= n[names[i1]];
						    	else{
									str+= ",";
									str+=n[names[i1]];
								}
					    	});
					    	if($("#"+objs[i1]).length>=1){
								$("#"+objs[i1]).val("");
								$("#"+objs[i1]).val(str);
							}else{
								$("[name='"+objs[i1]+"']").val("");
								$("[name='"+objs[i1]+"']").val(str);
							}
						 }
				    	return true;
				    }
					
			    },
			    cancelVal: '关闭',
			    cancel: true /*为true等价于function(){}*/
			}).zindex();
		}
}
/**
 * Jeecg Excel 导出
 * 代入查询条件
 */
function JeecgExcelExport(url,datagridId){
	var queryParams = $('#'+datagridId).datagrid('options').queryParams;
	$('#'+datagridId+'tb').find('*').each(function() {
	    queryParams[$(this).attr('name')] = $(this).val();
	});
	var params = '&';
	$.each(queryParams, function(key, val){
		params+='&'+key+'='+val;
	}); 
	var fields = '&field=';
	$.each($('#'+ datagridId).datagrid('options').columns[0], function(i, val){
		if(val.field != 'opt'){
			fields+=val.field+',';
		}
	}); 
	window.location.href = url+ encodeURI(fields+params);
}
/**
 * 自动完成的解析函数
 * @param data
 * @returns {Array}
 */
function jeecgAutoParse(data){
	var parsed = [];
    	$.each(data.rows,function(index,row){
    		parsed.push({data:row,result:row,value:row.id});
    	});
			return parsed;
}

/**
 * 下载文件请求 
 * @author xlThinkPad
 * @param url 
 * @param data string || Object
 * @param method nullable || 'POST' || 'GET'
 */
function myDownload(url,data,method){
	method = method != undefined ? method : "POST";
	if(url){
		var inputs = "";
		if(data){
			data = typeof data == 'string' ? data : $.param(data);
			$(data.split("&")).each(function(i,item){
				var par = this.split("=");
				inputs += '<input type="hidden" name="' + par[0] + '" value="' + par[1] + '" />';
			});
		}
		$('<form action="' + url + '" method="' + method + '">' + inputs + '</form>')
			.appendTo('body').submit().remove();
    }
}
/**
 * @author xlThinkPad
 * 省市级联
 * @param datagridName easyuidatagrid name
 * @param fieldName filed name
 * @param classIndex eg: a.b.c 1，那么b就是class类型的 c是b class 的属性
 */
function territoryLink(datagridName, fieldName,classIndex){
	classIndex = classIndex == undefined ? 0 : classIndex;//默认给0
	var pleaseChoice = "<option value=''>--请选择省--</option>";
	if(!fieldName){
		return;
	}
	var queryParams;//datagrid 额外参数
	var fnArr = fieldName.split(".");
	var id_of_field_tsTerritory = "";
	for(var i = 0;i < fnArr.length;i++ ){
		if(i != fnArr.length - 1){
			id_of_field_tsTerritory += fnArr[i] + "_";
		}else{
			id_of_field_tsTerritory += fnArr[i];
		}
	}
	var hide_field_of_tsTerritory_name = fieldName;
	var hide_field_of_parent_tsTerritory_name = "";
	for(var i = 0;i <= classIndex;i++){
		hide_field_of_parent_tsTerritory_name += fnArr[i] + ".";
	}
	hide_field_of_parent_tsTerritory_name += "TSTerritory.territoryName";
	var hide_field_of_tsTerritory_id = "tsTerritoryName";
	$("#"+id_of_field_tsTerritory).after($("<input type='hidden' name='"+hide_field_of_tsTerritory_name+"' id='"+hide_field_of_tsTerritory_id+"'/>"));
	$("#"+id_of_field_tsTerritory).replaceWith($("<select id='territoryL2' name='_territoryL2' width='100' style='width:164px;'></select>"));
	$("#territoryL2").append(pleaseChoice);
	
	$.ajax({
		url : "zyCommonController.do?queryTerritory",
		data : {
			"level" : 1
			},
		cache : false,
		dataType : 'json',
		type : 'POST',
		success : function(data){
			if(data.success){
				$.each(data.obj,function(i,n){
					$("#territoryL2").append($("<option value='"+n.ID+"'>"+n.territoryname+"</option>"));
				});
			}else{
				alert(data.msg);
			}
		}
	});
	var territoryL3 = $("<select id='territoryL3' name='_territoryL3' style='display:none;width:164px;' width='100'></select>");
	var allChoice = "<option value=''>---全部---</option>";
	$("#territoryL2").change(function(){
		var territoryId = $(this).children("option:selected").val();
		var territotyL2Html = $(this).children("option:selected").html();
		setHideTerrtoryVal(territoryId, territotyL2Html);
		$("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);//设置隐藏域的name
		deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
		if(territoryId == undefined || territoryId == ''){
			$("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);//设置隐藏域的name
			deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
			$("#territoryL3").remove();
		}else{
			$(this).after(territoryL3);
			$("#territoryL3 option").remove();
			$("#territoryL3").append(allChoice).show().change(function(){
				var territoryL3Val = $(this).children("option:selected").val();
				var territoryL3Html = $(this).children("option:selected").html();
				setHideTerrtoryVal(territoryL3Val, $(this).children("option:selected").html());
				if(territoryL3Val == undefined || territoryL3Val == ''){
					$("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);
					deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
					setHideTerrtoryVal(territoryId, territotyL2Html);
				}else{
					$("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);
					deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
				}
			});
			$.ajax({
				url : "zyCommonController.do?queryTerritory",
				data : {
					"level" : 2,
					"cityParentId" :  territoryId
					},
				cache : false,
				dataType : 'json',
				type : 'POST',
				success : function(data){
					if(data.success){
						$.each(data.obj,function(i,n){
							$("#territoryL3").append($("<option value='"+n.ID+"'>"+n.territoryname+"</option>"));
						});
					}else{
						alert(data.msg);
					}
				}
			});
		}
	});
	function setHideTerrtoryVal(val, html){
		if(val != undefined && val != ''){
			$("#"+hide_field_of_tsTerritory_id).val(html);
		}else{
			clearHideTerrtoryVal(hide_field_of_tsTerritory_id);
		}
	}
	function clearHideTerrtoryVal(id){
		$("#"+id).val("");
	}
	function deleteQueryParams(dgName,fildName){
		if(dgName){
			queryParams = $("#"+dgName).datagrid('options').queryParams;
			delete queryParams[fildName];	
		}
	}
}

/**
 * 服务类型级联
 * @param datagridName easyuidatagrid name
 * @param fieldName filed name
 * @param classIndex eg: a.b.c 1，那么b就是class类型的，c是b class 的属性
 */
function territoryLinks(datagridName, fieldName,classIndex){
    classIndex = classIndex == undefined ? 0 : classIndex;//默认给0
    var pleaseChoice = "<option value=''>--请选择--</option>";
    if(!fieldName){
        return;
    }
    var queryParams;//datagrid 额外参数
    var fnArr = fieldName.split(".");
    var id_of_field_tsTerritory = "";
    for(var i = 0;i < fnArr.length;i++ ){
        if(i != fnArr.length - 1){
            id_of_field_tsTerritory += fnArr[i] + "_";
        }else{
            id_of_field_tsTerritory += fnArr[i];
        }
    }
    var hide_field_of_tsTerritory_name = fieldName;
    var hide_field_of_parent_tsTerritory_name = "";
    for(var i = 0;i <= classIndex;i++){
        hide_field_of_parent_tsTerritory_name += fnArr[i] + ".";
    }
    hide_field_of_parent_tsTerritory_name += "CbsServiceTypeEntity.name";
    var hide_field_of_tsTerritory_id = "name";
    $("#"+id_of_field_tsTerritory).after($("<input type='hidden' name='"+hide_field_of_tsTerritory_name+"' id='"+hide_field_of_tsTerritory_id+"'/>"));
    $("#"+id_of_field_tsTerritory).replaceWith($("<select id='serviceType1' name='_serviceType1' style='width:164px;margin-right: 2px'></select>"));
    $("#serviceType1").append(pleaseChoice);

    $.ajax({
        url : "cbsServiceController.do?queryTerritory",
        data : {
            "level" : 0
        },
        cache : false,
        dataType : 'json',
        type : 'POST',
        success : function(data){
            if(data.success){
                $.each(data.obj,function(i,n){
                    $("#serviceType1").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                });
            }else{
                alert(data.msg);
            }
        }
    });
    var serviceType2 = $("<select id='serviceType2' name='_serviceType2' style='display:none;width:164px;margin-right: 2px;margin-bottom: 2px' onchange='changeServiceType2()' width='100'></select>");
    var allChoice = "<option value=''>---全部---</option>";
    $("#serviceType1").change(function(){
        var territoryId = $(this).children("option:selected").val();
        var territotyL2Html = $(this).children("option:selected").html();
        setHideTerrtoryVal(territoryId, territotyL2Html);
        $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);//设置隐藏域的name
        deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
        if(territoryId == undefined || territoryId == ''){
            $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);//设置隐藏域的name
            deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
            $("#serviceType2").remove();
        }else{
            $(this).after(serviceType2);
            $("#serviceType2 option").remove();
            $("#serviceType2").append(allChoice).show().change(function(){
                var serviceType2Val = $(this).children("option:selected").val();
                var serviceType2Html = $(this).children("option:selected").html();
                setHideTerrtoryVal(serviceType2Val, $(this).children("option:selected").html());
                if(serviceType2Val == undefined || serviceType2Val == ''){
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
                    setHideTerrtoryVal(territoryId, territotyL2Html);
                }else{
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
                }
            });
            $.ajax({
                url : "cbsServiceController.do?queryTerritory",
                data : {
                    "level" : 1,
                    "cityParentId" :  territoryId
                },
                cache : false,
                dataType : 'json',
                type : 'POST',
                success : function(data){
                    if(data.success){
                        $.each(data.obj,function(i,n){
                            $("#serviceType2").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                        });
                    }else{
                        alert(data.msg);
                    }
                }
            });
        }
    });
    function setHideTerrtoryVal(val, html){
        if(val != undefined && val != ''){
            $("#"+hide_field_of_tsTerritory_id).val(html);
        }else{
            clearHideTerrtoryVal(hide_field_of_tsTerritory_id);
        }
    }
    function clearHideTerrtoryVal(id){
        $("#"+id).val("");
    }
    function deleteQueryParams(dgName,fildName){
        if(dgName){
            queryParams = $("#"+dgName).datagrid('options').queryParams;
            delete queryParams[fildName];
        }
    }
}

/**
 * 故障分类级联
 * @param datagridName easyuidatagrid name
 * @param fieldName filed name
 * @param classIndex eg: a.b.c 1，那么b就是class类型的，c是b class 的属性
 */
function errorLinks(datagridName, fieldName,classIndex){
    classIndex = classIndex == undefined ? 0 : classIndex;//默认给0
    var pleaseChoice = "<option value=''>--请选择--</option>";
    if(!fieldName){
        return;
    }
    var queryParams;//datagrid 额外参数
    var fnArr = fieldName.split(".");
    var id_of_field_tsTerritory = "";
    for(var i = 0;i < fnArr.length;i++ ){
        if(i != fnArr.length - 1){
            id_of_field_tsTerritory += fnArr[i] + "_";
        }else{
            id_of_field_tsTerritory += fnArr[i];
        }
    }
    var hide_field_of_tsTerritory_name = fieldName;
    var hide_field_of_parent_tsTerritory_name = "";
    for(var i = 0;i <= classIndex;i++){
        hide_field_of_parent_tsTerritory_name += fnArr[i] + ".";
    }
    hide_field_of_parent_tsTerritory_name += "CbsErrorTypeEntity.name";
    var hide_field_of_tsTerritory_id = "name";
    $("#"+id_of_field_tsTerritory).after($("<input type='hidden' name='"+hide_field_of_tsTerritory_name+"' id='"+hide_field_of_tsTerritory_id+"'/>"));
    $("#"+id_of_field_tsTerritory).replaceWith($("<select id='errorType1' name='_errorType1' width='100' style='width:164px;margin-right: 2px;margin-bottom: 2px'></select>"));
    $("#errorType1").append(pleaseChoice);

    $.ajax({
        url : "cbsServiceController.do?queryError",
        data : {
            "level" : 0
        },
        cache : false,
        dataType : 'json',
        type : 'POST',
        success : function(data){
            if(data.success){
                $.each(data.obj,function(i,n){
                    $("#errorType1").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                });
            }else{
                alert(data.msg);
            }
        }
    });
    var errorType2 = $("<select id='errorType2' name='_errorType2' style='display:none;width:164px;margin-right: 2px;margin-bottom: 2px' onchange='changeErrorType2()' width='100'></select>");
    var allChoice = "<option value=''>---全部---</option>";
    $("#errorType1").change(function(){
        var territoryId = $(this).children("option:selected").val();
        var territotyL2Html = $(this).children("option:selected").html();
        setHideTerrtoryVal(territoryId, territotyL2Html);
        $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);//设置隐藏域的name
        deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
        if(territoryId == undefined || territoryId == ''){
            $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);//设置隐藏域的name
            deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
            $("#errorType2").remove();
        }else{
            $(this).after(errorType2);
            $("#errorType2 option").remove();
            $("#errorType2").append(allChoice).show().change(function(){
                var errorType2Val = $(this).children("option:selected").val();
                var errorType2Html = $(this).children("option:selected").html();
                setHideTerrtoryVal(errorType2Val, $(this).children("option:selected").html());
                if(errorType2Val == undefined || errorType2Val == ''){
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
                    setHideTerrtoryVal(territoryId, territotyL2Html);
                }else{
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
                }
            });
            $.ajax({
                url : "cbsServiceController.do?queryError",
                data : {
                    "level" : 1,
                    "cityParentId" :  territoryId
                },
                cache : false,
                dataType : 'json',
                type : 'POST',
                success : function(data){
                    if(data.success){
                        $.each(data.obj,function(i,n){
                            $("#errorType2").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                        });
                    }else{
                        alert(data.msg);
                    }
                }
            });
        }
    });
    function setHideTerrtoryVal(val, html){
        if(val != undefined && val != ''){
            $("#"+hide_field_of_tsTerritory_id).val(html);
        }else{
            clearHideTerrtoryVal(hide_field_of_tsTerritory_id);
        }
    }
    function clearHideTerrtoryVal(id){
        $("#"+id).val("");
    }
    function deleteQueryParams(dgName,fildName){
        if(dgName){
            queryParams = $("#"+dgName).datagrid('options').queryParams;
            delete queryParams[fildName];
        }
    }
}

/**
 * 关键备件分类级联
 * @param datagridName easyuidatagrid name
 * @param fieldName filed name
 * @param classIndex eg: a.b.c 1，那么b就是class类型的，c是b class 的属性
 */
function equipmentLinks(datagridName, fieldName,classIndex){
    classIndex = classIndex == undefined ? 0 : classIndex;//默认给0
    var pleaseChoice = "<option value=''>--请选择--</option>";
    if(!fieldName){
        return;
    }
    var queryParams;//datagrid 额外参数
    var fnArr = fieldName.split(".");
    var id_of_field_tsTerritory = "";
    for(var i = 0;i < fnArr.length;i++ ){
        if(i != fnArr.length - 1){
            id_of_field_tsTerritory += fnArr[i] + "_";
        }else{
            id_of_field_tsTerritory += fnArr[i];
        }
    }
    var hide_field_of_tsTerritory_name = fieldName;
    var hide_field_of_parent_tsTerritory_name = "";
    for(var i = 0;i <= classIndex;i++){
        hide_field_of_parent_tsTerritory_name += fnArr[i] + ".";
    }
    hide_field_of_parent_tsTerritory_name += "CbsEquipmentErrorTypeEntity.name";
    var hide_field_of_tsTerritory_id = "name";
    $("#"+id_of_field_tsTerritory).after($("<input type='hidden' name='"+hide_field_of_tsTerritory_name+"' id='"+hide_field_of_tsTerritory_id+"'/>"));
    $("#"+id_of_field_tsTerritory).replaceWith($("<select id='equipmentErrorType1' name='_equipmentErrorType1' width='100' style='width:164px;margin-right: 2px;margin-bottom: 2px'></select>"));
    $("#equipmentErrorType1").append(pleaseChoice);

    $.ajax({
        url : "cbsServiceController.do?queryEquipment",
        data : {
            "level" : 0
        },
        cache : false,
        dataType : 'json',
        type : 'POST',
        success : function(data){
            if(data.success){
                $.each(data.obj,function(i,n){
                    $("#equipmentErrorType1").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                });
            }else{
                alert(data.msg);
            }
        }
    });
    var equipmentErrorType2 = $("<select id='equipmentErrorType2' name='_equipmentErrorType2' style='display:none;width:164px;margin-right: 2px;margin-bottom: 2px' width='100'></select>");
    var allChoice = "<option value=''>---全部---</option>";
    $("#equipmentErrorType1").change(function(){
        var territoryId = $(this).children("option:selected").val();
        var territotyL2Html = $(this).children("option:selected").html();
        setHideTerrtoryVal(territoryId, territotyL2Html);
        $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);//设置隐藏域的name
        deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
        if(territoryId == undefined || territoryId == ''){
            $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);//设置隐藏域的name
            deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
            $("#equipmentErrorType2").remove();
        }else{
            $(this).after(equipmentErrorType2);
            $("#equipmentErrorType2 option").remove();
            $("#equipmentErrorType2").append(allChoice).show().change(function(){
                var equipmentErrorType2Val = $(this).children("option:selected").val();
                var equipmentErrorType2Html = $(this).children("option:selected").html();
                setHideTerrtoryVal(equipmentErrorType2Val, $(this).children("option:selected").html());
                if(equipmentErrorType2Val == undefined || equipmentErrorType2Val == ''){
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_parent_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_tsTerritory_name);//删除datagrid queryParams中当前 name
                    setHideTerrtoryVal(territoryId, territotyL2Html);
                }else{
                    $("#"+hide_field_of_tsTerritory_id).attr("name",hide_field_of_tsTerritory_name);
                    deleteQueryParams(datagridName, hide_field_of_parent_tsTerritory_name);//删除datagrid queryParams中当前 name
                }
            });
            $.ajax({
                url : "cbsServiceController.do?queryEquipment",
                data : {
                    "level" : 1,
                    "cityParentId" :  territoryId
                },
                cache : false,
                dataType : 'json',
                type : 'POST',
                success : function(data){
                    if(data.success){
                        $.each(data.obj,function(i,n){
                            $("#equipmentErrorType2").append($("<option value='"+n.id+"'>"+n.name+"</option>"));
                        });
                    }else{
                        alert(data.msg);
                    }
                }
            });
        }
    });
    function setHideTerrtoryVal(val, html){
        if(val != undefined && val != ''){
            $("#"+hide_field_of_tsTerritory_id).val(html);
        }else{
            clearHideTerrtoryVal(hide_field_of_tsTerritory_id);
        }
    }
    function clearHideTerrtoryVal(id){
        $("#"+id).val("");
    }
    function deleteQueryParams(dgName,fildName){
        if(dgName){
            queryParams = $("#"+dgName).datagrid('options').queryParams;
            delete queryParams[fildName];
        }
    }
}


/**
 * 巡检流程记录表格
 */
function drawPlanRecordTable(ipId){
	$.ajax({
		url : "zyCommonController.do?queryPlanRecord",
		data : {
			"ipId" : ipId
			},
		cache : false,
		dataType : 'json',
		type : 'POST',
		success : function(data){
			if(data.success){
				var formData = data.obj;
				var table = $('<table class="ipRecordTable"></table>');
				$(table).append('<tr><th>操作人</th><th>操作时间</th><th>操作内容</th><th>附件</th></tr>');
				$(formData).each(function(r,rData){
					var filename = "";
					var finleId = "";
					if(rData.fileName!=""&&rData.fileName!="undefined"){
                        filename = rData.fileName;
                        finleId=rData.fileId;
					}
					$(table).append('<tr><td style="min-width:60px;">'+rData.createName+'</td>' +
						'<td style="min-width:120px;">'+rData.createDate+'</td>' +
						'<td style="max-width: 78%;word-wrap : break-word ;word-break: break-all;">'+rData.remark+'</td>' +
						'<td style="min-width:120px;">' +
						'<a href="fileUploadController.do?downLoadFile&fileLogId='+finleId+'" target="_blank" style="color: blue;">'+filename+'</a></td></tr>');
				});
				$("#planRecordDiv").html(table);
				$("#planRecordDiv").append("<br/>");
			}else{
				tip(data.msg);
			}
		}
	});
}


/**
 * 通用 绑定搜索条件 弹出式选择BP页
 */
function chooseBpForQueryParam(bpCodeId){
	$("#"+bpCodeId).removeAttr("onkeypress onkeydown").focus(function(){
//		createwindow("选择BP","zyCommonController.do?goQueryBp&bpCodeId="+bpCodeId,800,500);
		if (typeof(windowapi) == 'undefined') {
			$.dialog({
				content: 'url:zyCommonController.do?goQueryBp&bpCodeId='+bpCodeId,
				zIndex: 2100,
				title: '选择BP',
				lock: true,
				width: '800px',
				height: '500px',
				left: '85%',
				top: '65%',
				opacity: 0.4,
				init: function() {
					top.myWindow = window;
				},
				button: [{
					name: '确定',
					callback: clickcallback,
					focus: true
				}, {
					name: '取消',
					callback: function() {}
				}]
			});
		} else {
			$.dialog({
				content: 'url:zyCommonController.do?goQueryBp&bpCodeId='+bpCodeId,
				zIndex: 2100,
				title: '选择BP',
				lock: true,
				parent: windowapi,
				width: '800px',
				height: '500px',
				left: '85%',
				top: '65%',
				opacity: 0.4,
				init: function() {
					top.myWindow = window;
				},
				button: [{
					name: '确定',
					callback: clickcallback,
					focus: true
				}, {
					name: '取消',
					callback: function() {}
				}]
			});
		}
	});
	function clickcallback() {
		iframe = this.iframe.contentWindow;
		var text = iframe.getorgListSelections('bpCode');
		if ($('#'+bpCodeId).length >= 1) {
			$('#'+bpCodeId).val(text);
			$('#'+bpCodeId).blur();
		}
		if ($("input[name='"+bpCodeId+"']").length >= 1) {
			$("input[name='"+bpCodeId+"']").val(text);
			$("input[name='"+bpCodeId+"']").blur();
		}
	}
}

/**
 * @params show 是否显示遮罩层
 * @params tipmsg 遮罩层提示信息
 * @params lockarea 遮挡区域
 */
function lockmask(show, tipmsg,lockarea){
	tipmsg = tipmsg != undefined ? tipmsg : '处理中...';
	lockarea = lockarea != undefined ? lockarea : "top";
	if($("#_lockmask",window[lockarea].document) != undefined && $("#_lockmask",window[lockarea].document).length > 0){
		if(show){
			$("#_lockmask",window[lockarea].document).show();
			$("#_mask_ct",window[lockarea].document).html(tipmsg).show();
		}else{
			$("#_lockmask",window[lockarea].document).hide();
			$("#_mask_ct",window[lockarea].document).hide();
		}
	}else{
		var lockmask = $('<div id="_lockmask" style="position: fixed; left: 0px; top: 0px; width: 100%; height: 100%; overflow: hidden; z-index: 99999;background-color:#DCE2F1;opacity:.5;"></div>'+
				'<div id="_mask_ct" style="display:block; left:50%; margin-left:50px;background-color:#96B8E7;background:#ffffff url(\'plug-in/easyui/themes/default/images/loading.gif\') no-repeat scroll 5px center; ' + 
				'position:absolute; z-index: 100000;top:50%; margin-top:-20px; padding:12px 5px 10px 30px; width:auto; height:16px; border:2px solid #2288cc;">'+ tipmsg +'</div>');
		$("body",window[lockarea].document).append(lockmask);
		lockmask.show();
	}
	
} 


function reziseDatagridInViewPage(datagridDivId, orignParentDivClass, minHeight){
	var thisParentDiv = $("#"+ datagridDivId).parents("." + orignParentDivClass);
	var height = $(thisParentDiv).find(".datagrid-btable").height();
	console.log(height);
	console.log(minHeight);
	if(height > minHeight){
		height += 60;
		$(thisParentDiv).find(".datagrid-wrap").height(height);
		$(thisParentDiv).find(".datagrid-view").height(height);
		$(thisParentDiv).find(".datagrid-body").height(height);
		$(thisParentDiv).height(height);
	}
}
